<?php $this->_extends('../_layouts/default_layout');?>
<?php $this->_block('contents');?>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat: 'yy-mm-dd', changeMonth: true});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<?php include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
	<tr>
		<th>创建日期</th>
		<td>
			<input type="text" name="begin_create_time" class="datepicker" value="<?=isset($_GET['begin_create_time']) ? $_GET['begin_create_time'] : ''?>"/> to 
			<input type="text" name="end_create_time" class="datepicker" value="<?=isset($_GET['end_create_time']) ? $_GET['end_create_time'] : ''?>"/>
		</td>
	</tr>
	<tr>
		<th>产品编号</th>
		<td><input type="text" name="product_basic_number" value="<?=isset($_GET['product_basic_number']) ? $_GET['product_basic_number'] : ''?>" /> 输入产品编号后六位例如：000001</td>
	</tr>
	<tr>
		<th>创建人员</th>
		<td>
			<select name="create_user_id">
				<option value="">请选择..</option>
				<?foreach ($department as $d):?>
				<optgroup label="<?=$d['name']?>">
				<?foreach ($user as $u):?>
				<?if ($u['user_department_id'] == $d['id']):?>
				<option value="<?=$u['id']?>" <?if (isset($_GET['create_user_id']) && $_GET['create_user_id'] == $u['id']) echo "selected='selected'"?>><?=$u['name']?></option>
				<?endif;?>
				<?endforeach;?>
				</optgroup>
				<?endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<th></th>
		<td><input type="submit" class="button" value="查询" /></td>
	</tr>
</table>
</form>
</fieldset>
<table class="list_table" width="100%">
	<tr>
		<th width="30">ID</th>
		<th width="350">产品</th>
		<th width="50">单价</th>
		<th width="50">数量</th>
		<th width="100">创建时间</th>
		<th width="70">创建人</th>
		<th width="">原因</th>
		<th width="100">损耗金额</th>
		<th width="100">操作</th>
	</tr>
	<?foreach ($purchase_loss as $pl):?>
	<tr>
		<td><?=$pl['id']?></td>
		<td><?="（" . $pl['number'] . "）" . $pl['name']?></td>
		<td><?=sprintf('%.2f', $pl['price'])?></td>
		<td><?=$pl['quantity']?></td>
		<td><?=isset($pl['create_time']) ? date('Y-m-d', strtotime($pl['create_time'])) : ''?></td>
		<td><?=$pl['create_user_name']?></td>
		<td><?=$pl['reason']?></td>
		<td><?=sprintf('%.2f', $pl['price'] * $pl['quantity'])?></td>
		<td>
			<a class="edit" href="<?=url('Purchase::Loss/PurchaseAudit', array('purchase_loss_id' => $pl['id']))?>">审核通过</a>
		</td>
	</tr>
	<?endforeach;?>
</table>
<?=$page;?>
<?php $this->_endblock();?>